<?

//require_once(dirname(__FILE__) . '/array.php');

class bf_session extends bf_array {

	protected $opts;
	
	public function __construct($options = array()) {
		$this->opts = array_merge(array(
			'expiration-time' => 60*60*24, // seconds
			'name' => 'bf_session_' . md5(bf_url::get_host()),
			'save-path' => null, // using default configuration
		), $options);
	}

	public function start() {
		session_name($this->opts['name']);
		session_cache_limiter('public');
		session_cache_expire($this->opts['expiration-time'] / 60); // minutes
		ini_set('session.gc_maxlifetime', $this->opts['expiration-time']); // seconds
		if ($this->opts['save-path']) {
			ini_set('session.save_path', $this->opts['save-path']);
		}
		if (!@session_start()) {
			exit(0);
		}
		$this->data = &$_SESSION;
	}
}

?>